// pages/home/search/search-result/search-result.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    myArray:[],
    page:'',
    context:''
  },

  onLoad(option) {
    const eventChannel = this.getOpenerEventChannel()
    eventChannel.emit('acceptDataFromOpenedPage', {data: 'test'});
    eventChannel.emit('someEvent', {data: 'test'});
    // 监听 acceptDataFromOpenerPage 事件，获取上一页面通过 eventChannel 传送到当前页面的数据
    const that =this
    eventChannel.on('acceptDataFromOpenerPage', function(data) {
      that.setData({page:data.page,context:data.context})
      
    })
    console.log(this.data.page,this.data.context)
    wx.request({
      url: `http://localhost:8080/query/${this.data.page}`,
      data:{
        context:this.data.context
      },
      header: {
        'content-type': 'application/json' // 默认值
      }, 
      success (res) {
        console.log(res.data)
        that.setData({myArray:res.data})
      }
    })
  },
  onChange(){}
  
})